#include <bits/stdc++.h>
using namespace std;


int main(){
    freopen("T01.txt", "r", stdin);

    long long n, a, b, nmax, nmin, diff;
    cin >> n;
    
    while(n--){
        cin >> a >> b;
        nmax = max(a, b);
        nmin = min(a, b);
        diff = nmax - nmin;

        long i = 1, sum = 0;
        while(sum < diff){
            sum += i;
            ++i;
        }
        
        sum -= diff;
        while(sum % 2 != 0){
            sum += i;
            ++i;
        }
        cout << i << endl;


    }
}


